function [a,flag,param] = undirE(param, Q, aFeasible, iState, aFCat, a, t, n)
% implementation of the brute force undirected exploration plus
% exploitation.
% tobias siegfried, 24.04.07

rN = rand;
if rN < param.exploreP(n)
    a(t) = rand * aFeasible; 
    flag = 0;
    %param.testExplore(t) = 1;
else
    % search for action with max(Q) given state
    te = Q(iState,1:aFCat); % this is somewhat faster than the code in line 62.
    iAMax = find(te == max(te)); 
    iAMax = iAMax(1); % get rid of non-uniqueness
    a(t) = param.actionV{n}(iAMax);% + ceil(rand*param.discQ(n)); % CHECK THIS!
    if a(t) > aFeasible, a(t) = aFeasible; end
    flag = 1;
end